package com.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 运行时常量池, String.intern()
 * @author: yuchi_huang (yuchi_huang@sui.com)
 * @date: 18/3/15
 * @modified By:
 */
public class RuntimeConstantPoolIntern {

    public static void main(String[] args) {

        //深入理解Java虚拟机 P57

        String str1 = new StringBuilder("计算机").append("软件").toString();
        System.out.println(str1.intern() == str1); //true

        String str2 = new StringBuilder("ja").append("va").toString();
        System.out.println(str2.intern() == str2); //false, java是关键字, jvm初始化时候就被放进常量池

        String str3 = new StringBuilder("ma").append("in").toString();
        System.out.println(str3.intern() == str3); //main也是关键字

    }

}
